﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DungeonGenerator.Tests
{
    using System.Windows;

    using FluentAssertions;

    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Diagnostics;

    [TestClass]
    public class WindowsBaseExtensionsTests
    {
        
        [TestMethod]
        public void RectRightEqualsXPlusWidth()
        {
            var rect = new Rect(0, 0, 4, 4);

            rect.Right.Should().Be(rect.X + rect.Width);

        }

        [TestMethod]
        public void RectBottomEqualsYPlusHeight()
        {
            var rect = new Rect(0, 0, 4, 4);

            rect.Bottom.Should().Be(rect.Y + rect.Height);

        }

        [TestMethod]
        public void RectSmallerWidth()
        {
            var rect = new Rect(0, 0, 4, 4);
            var actual = new Rect(0,0,3,3);

            actual.Right.Should().Be(rect.Right - 1);


        }

        [TestMethod]
        public void RectFromOneLessDoesNotContainOrigin()
        {
            var rect = new Rect(0, 0, 4, 4);
            var actual = new Rect(1, 1, 3, 3);
            actual.Contains(rect.TopLeft).Should().BeFalse();

        }
        

        [TestMethod]
        public void DeflateDoesNotContainExpandedTopLeft()
        {
            var rect = new Rect(0, 0, 4, 4);
            var actual = rect.Deflate();
            actual.Contains(rect.TopLeft).Should().BeFalse();
        }

        [TestMethod]
        public void DeflateDoesNotContainExpandedBottomLeft()
        {
            var rect = new Rect(0, 0, 4, 4);
            var actual = rect.Deflate();
            actual.Contains(rect.BottomLeft).Should().BeFalse();
        }

        [TestMethod]
        public void DeflateDoesNotContainExpandedBottomRight()
        {
            var rect = new Rect(0, 0, 4, 4);
            var actual = rect.Deflate();
            actual.Contains(rect.BottomRight).Should().BeFalse();
        }

        [TestMethod]
        public void DeflateIsInset()
        {
            var rect = new Rect(0, 0, 4, 4);
            var actual = rect.Deflate();
            
            actual.Contains(rect).Should().BeFalse();
            rect.Contains(actual).Should().BeTrue();
            actual.X.Should().Be(rect.X + 1);
            Debug.WriteLine("X is ok");
            actual.Y.Should().Be(rect.Y + 1);
            Debug.WriteLine("Y is ok");
            actual.Right.Should().Be(rect.Right - 1);
            Debug.WriteLine("Right is ok");
            actual.Left.Should().Be(rect.Left + 1);
            Debug.WriteLine("Left is ok");
        }

        [TestMethod]
        public void ContainsExlusiveIsFalseForOrigin()
        {
            var rect = new Rect(0, 0, 4, 4);
            rect.ContainsExclusive(new PointI { X = 0, Y = 0 }).Should().BeFalse();
        }

        [TestMethod]
        public void ContainsExlusiveIsFalseForBottomRight()
        {
            var rect = new Rect(0, 0, 4, 4);
            rect.ContainsExclusive(new PointI { X = 4, Y = 4 }).Should().BeFalse();
        }
    }
}
